﻿function goprev(type) {
    var _url = location.href;
    var index = _url.indexOf('?');
    if (index != 0)
        _url = _url.substring(0, index);
    var y = gup('year');
    if (y == '')
        y = new Date().getFullYear();

    if (type == 0)
        y = parseInt(y) - 1;
    else
        y = parseInt(y) + 1;
    _url += '?year=' + y;
    if (gup('vid') != '')
        _url += '&vid=' + gup('vid');
    if (gup('v') != '')
        _url += '&v=' + gup('v');
    location.href = _url;
}
function direct(year) {

    var _url = location.href;
    var index = _url.indexOf('?');
    if (index != -1)
        _url = _url.substring(0, index);

    _url += '?year=' + year;
    if (gup("vid") != '') {
        _url += '&vid=' + gup("vid");
    }
    if (gup("v") != '') {
        _url += '&v=' + gup("v");
    }
    if (gup("month") != '') {
        _url += '&month=' + gup("month");
    }
    if (gup("typeval") != '') {
        _url += '&typeval=' + gup("typeval");
    }
    window.location.href = _url;
}
function gup(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return results[1];
}
function directquarter(m) {
    var _url = location.href;
    var index = _url.indexOf('?');
    if (index != 0)
        _url = _url.substring(0, index);
    _url += '?q=' + m;
    if (gup("v") != '') {
        _url += '&v=' + gup("v");
    }
    if (gup("year") != '') {
        _url += '&year=' + gup("year");
    }
    window.location.href = _url;
}
function directmonth(m) {
    var _url = location.href;
    var index = _url.indexOf('?');
    if (index != 0)
        _url = _url.substring(0, index);
    _url += '?month=' + m;
    if (gup("v") != '') {
        _url += '&v=' + gup("v");
    }
    if (gup("year") != '') {
        _url += '&year=' + gup("year");
    }
    window.location.href = _url;
}

function halfyear(half) {
    var _url = location.href;
    var index = _url.indexOf('?');
    if (index != 0)
        _url = _url.substring(0, index);
    _url += '?h=' + half;
    if (gup("v") != '') {
        _url += '&v=' + gup("v");
    }
    if (gup("year") != '') {
        _url += '&year=' + gup("year");
    }
    window.location.href = _url;
}
function pickedFunc() {

    var _year = (new Date()).getFullYear();
    var iYear = document.getElementById('iYear');
    if (iYear != null)
        _year = iYear.value;
    if (_year == '') {
        _year = (new Date()).getFullYear();
    }
    direct(_year);
}
function OverChangeClass(obj) {
    if (obj.className != "Cur")
        obj.className = 'Over01'
}
function ReturnClass(obj) {
    obj.className = obj.oldclass;
}
$(document).ready(
function() {
    var href = location.href;

    var index = href.lastIndexOf('.aspx');
    var index1 = href.lastIndexOf('/');
    var params = href.substring(index + 5, href.length);

    href = href.substring(index1 + 1, index);
    var params = href;

    if (document.getElementById('sType') != null) {
        $("#sType").val(href);
        $("#sType").change(function() {
            var params = '';
            var year = gup('year');
            if (year != '')
                params += '&year=' + year;
            var v = gup('v');
            if (v != '')
                params += '&v=' + v;
            v = gup('vid');
            if (v != '')
                params += '&vid=' + v;
            if (params != '')
                params = '?' + params.substring(1, params.length);

            location.href = $("#sType").val() + ".aspx" + params;
        }
    );

    }
    if (document.getElementById('sType2') != null) {
        var typeval = gup("typeval");
        $("#sType2").val(typeval);
        $("#sType2").change(function() {
            var year = gup('year');
            var params = '';
            if (year != '')
                params += '&year=' + year;
            location.href = "Index.aspx?typeval=" + $(this).val() + params + '&nc=' + Math.random();
        });
    }
}
);